package com.sikaryofficial.backend.utils;

import cn.hutool.core.util.NumberUtil;

import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 数字格式化
 * @date : 2023/12/06 20:16
 */
public class LikesDataFormatUtil {

    public static String formatNumber(Integer inputNum) {
        String format ;
        if(Objects.isNull(inputNum)){
            return "0";
        }
        if(inputNum >= 1000 && inputNum < 10000000){
            format = NumberUtil.decimalFormat("0.#k", Double.valueOf(inputNum / 1000.0) );
        }else if(inputNum >= 10000000){
            format = NumberUtil.decimalFormat("0.#m", Double.valueOf(inputNum / 1000000.0) );
        }else{
            format = inputNum.toString();
        }
        return format;
    }
}
